package com.example.demo.mapper;

import com.example.demo.entity.Artical;
import com.example.demo.entity.Book;
import com.example.demo.entity.BookVO;
import com.example.demo.entity.Jieyue;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface JieyueMapper {
    //借书流程
    public int jieyue(Book book);
    //查询分页
    List<Book> jieyuepage(BookVO bookVO);
    //查询总条数
    Integer jieyuecount(BookVO bookVO);
    //id查询
    @Select("SELECT bj.`borrowtime`," +
            "bj.`returntime`," +
            "bj.borid," +
            "bj.book_id," +
            "bj.user_id," +
            "bk.*," +
            "u.id AS uid," +
            "u.`username` FROM b_bookjieyue AS bj " +
            "LEFT JOIN b_bookguanli AS bk " +
            "ON bj.`book_id` = bk.`id` " +
            "LEFT JOIN t_comment AS u ON bj.`user_id` = u.`id` WHERE borid=#{id}")
    public BookVO xiangqing(Integer id);
    //生成借阅记录
    public Integer addjilu(Jieyue jieyue);
    //还书流程
    public int huanshu(Book book);
    //更新还书记录
    public int updatejilu(Jieyue jieyue);
    //用户个人记录
//    @Select("SELECT bj.`borrowtime`,\n" +
//            "        bj.`returntime`,\n" +
//            "        bj.borid,\n" +
//            "        bj.book_id,\n" +
//            "        bj.user_id,\n" +
//            "        bk.*,\n" +
//            "        u.id AS uid,\n" +
//            "        u.`username`\n" +
//            "        FROM b_bookjieyue AS bj\n" +
//            "        LEFT JOIN b_bookguanli AS bk ON bj.`book_id` = bk.`id`\n" +
//            "        LEFT JOIN t_comment AS u ON bj.`user_id` = u.`id` WHERE u.id=#{id}")
    public  List<BookVO> geren(BookVO bookVO);

}
